package cn.com.dcsgo.design.pattern.builder.car;

/**
 * 汽车说明书各个生产步骤具体实现
 *
 * @author Dcsgo
 * @since 21/7/2025 上午 10:26
 */

public class CarManualBuilder implements Builder {
    private Manual result;


    @Override
    public void reset() {
        result = new Manual();
    }

    @Override
    public void setSeats(int number) {
        result.setSeats("该车有: " + number + " 个座位");
    }

    @Override
    public void setEngine(Engine engine) {
        result.setEngine("该车配备: " + engine.getName());
    }

    @Override
    public void setTripComputer(String tripComputer) {
        result.setTripComputer("该车配备: " + tripComputer);
    }

    @Override
    public void setGps(String gps) {
        result.setGps("该车配备: " + gps);
    }

    public Manual getResult() {
        if (result == null) {
            throw new IllegalStateException("汽车说明书尚未生产完成");
        }
        Manual builtManual = result;
        result = null;
        return builtManual;
    }
}
